package com.yuntu.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yuntu.pojo.Position;
import com.yuntu.service.position.PositionService;
import com.yuntu.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.Wrapper;

/**
 * @author Dandan
 * @创建日期 2022/11/1 16:26
 * @文件描述
 */
@Controller
@RequestMapping("pos")
public class PositionController {
    @Autowired
    PositionService positionService;

    @RequestMapping("getAll")
    @ResponseBody
    public Result getAll(){
        return new Result(positionService.list(),200,"");
    }

    @RequestMapping("getAllByDep")
    @ResponseBody
    public Result getAllByDep(Position pos){
        QueryWrapper<Position> wrapper = new QueryWrapper<>();
        wrapper.eq(pos.getDepartmentId() != null, "department_id", pos.getDepartmentId());
        return new Result(positionService.list(),200,"");
    }

    @RequestMapping("getAllInfo")
    @ResponseBody
    public Result getAllInfo(@RequestBody Position position){
        return new Result(positionService.getAllInfo(position),200,"");
    }
}
